<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('Banner/index')}">轮播图列表</a></li>
        <li><a href="{:url('Banner/add')}">添加轮播图</a></li>
    </ul>
    <form class="well form-inline margin-top-20" method="get" action="{:url('Banner/index')}">
        <input type="text" class="form-control" name="keyword" style="width: 200px;" value="{:input('request.keyword/s','')}" placeholder="请输入id">
        <input type="submit" class="btn btn-primary" value="搜索" />
        <a class="btn btn-danger" href="{:url('Banner/index')}">清空</a>
    </form>
    <form method="post" class="js-ajax-form margin-top-20" action="{:url('Banner/order')}">
        <div class="table-actions">
            <button class="btn btn-sm btn-primary js-ajax-submit" type="submit">排序</button>
        </div>
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th width="16"><label><input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x"></label></th>
                <th width="50">{:lang('SORT')}</th>
                <th width="50">ID</th>
                <th>图片</th>
                <th>地址链接</th>
                <th>是否显示</th>
                <th width="120">操作</th>
            </tr>
            </thead>
            <tbody>
            <volist name="bannerList" id="banner">
                <tr>
                    <td><input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]" value="{$banner.id}"></td>
                    <td><input name="list_orders[{$banner.id}]" class="input input-order mr5" type="text" style="width: 50px;" value="{$banner.list_order}"></td>
                    <td>{$banner.id}</td>
                    <td><img src="/upload/{$banner.image}" style="height: 40px; width: 80px;"></td>
                    <td>{$banner.url}</td>
                    <td>
                        <eq name="$banner.switch" value="1">
                            <button type="button" class="btn btn-success toggle-switch" data-id="{$banner.id}">是</button>
                            <else/>
                            <button type="button" class="btn btn-danger toggle-switch" data-id="{$banner.id}">否</button>
                        </eq>
                    </td>
                    <td>
                        <a class="btn btn-xs btn-primary" href="{:url('Banner/edit',array('id'=>$banner.id))}">{:lang('EDIT')}</a>
                        <a class="btn btn-xs btn-danger js-ajax-delete" href="{:url('Banner/delete',array('id'=>$banner.id))}">{:lang('DELETE')}</a>
                    </td>
                </tr>
            </volist>
            </tbody>
        </table>
        <div class="pagination">{$page}</div>
    </form>
</div>
<script src="__STATIC__/js/admin.js?v={$_static_version}"></script>
<script>
    $(document).ready(function() {
        $('.toggle-switch').click(function() {
            var button = $(this);
            var id = button.data('id');
            $.post("{:url('Banner/toggleSwitch')}", {id: id}, function(data) {
                if (data.status === 1) {
                    if (data.switch === 1) {
                        button.removeClass('btn-danger').addClass('btn-success').text('是');
                    } else {
                        button.removeClass('btn-success').addClass('btn-danger').text('否');
                    }
                } else {
                    alert(data.msg);
                }
            }, 'json');
        });
    });
</script>
</body>
</html>
